package org.easy.eao.spring.jpa.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@Entity
@Table(name = "exam")
@NamedQueries(value = {
	@NamedQuery(name="Exam.findStudentGrade", 
		query="from Exam e where e.student = :student and e.subject in (:subjects)"),
	@NamedQuery(name="Exam.findByStudent", 
		query="from Exam e where e.student = :student order by e.grade"),
	@NamedQuery(name="Exam.findByStudent[count]", 
		query="select count(*) from Exam e where e.student = :student order by e.grade"),
	@NamedQuery(name="Exam.listByStudent", 
		query="from Exam e where e.student = ? order by e.grade"),
	@NamedQuery(name="Exam.all", 
		query="from Exam e order by e.grade"),
	@NamedQuery(name="Exam.all[count]", 
		query="select count(*) from Exam e order by e.grade")
})
public class Exam {

	private Integer id;
	private String subject;
	private String student;
	private int grade;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(length = 20, nullable = false)
	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	@Column(length = 20, nullable = false)
	public String getStudent() {
		return student;
	}

	public void setStudent(String student) {
		this.student = student;
	}

	@Column(nullable = false)
	public int getGrade() {
		return grade;
	}

	public void setGrade(int grade) {
		this.grade = grade;
	}

}
